/**
Company: Sarkar software technologys
WebSite: http://www.sarkar.cn
Author: yeganaaa
Date : 6/1/18
Time: 11:51 PM
 */

package Cn.Sarkar.MMS.LayerOne

import Cn.Sarkar.Entities.Common.Additional.IDescription
import Cn.Sarkar.Entities.Common.Additional.IName
import Cn.Sarkar.Entities.MMS.Additional.ICountry
import Cn.Sarkar.Entities.MMS.Independent.Wallet.IMemberShipLevel
import Cn.Sarkar.Entities.MMS.ToJsonEntities.JCountry
import Cn.Sarkar.Entities.MMS.ToJsonEntities.JMemberShipLevel
import Cn.Sarkar.Entities.ToJsonEntities.JDescription
import Cn.Sarkar.Entities.ToJsonEntities.JName
import Cn.Sarkar.MMS.Entities.Additional.Country


fun IName.convertToJ(): JName {
    val retv = JName()
    retv.ug = this.ug
    retv.zh = this.zh
    retv.en = this.en
    retv.kz = this.kz
    retv.ru = this.ru
    retv.category = this.category
    return retv
}

fun IDescription.convertToJ(): JDescription {
    val retv = JDescription()
    retv.ug = this.ug
    retv.zh = this.zh
    retv.en = this.en
    retv.kz = this.kz
    retv.ru = this.ru
    retv.category = this.category
    return retv
}

fun IMemberShipLevel.convertToJ(): JMemberShipLevel {
    val retv = JMemberShipLevel()
    retv.name = this.name.convertToJ()
    retv.description = this.description.convertToJ()
    return retv
}

fun ICountry.convertToJ(): JCountry {
    val retv = JCountry()

    retv.parentId = this.parent?.run {
        this as Country
    } ?.id ?: -1

    retv.id = (this as Country).id
    retv.createdTime = this.createdTime
    retv.lastUpdatedTime = this.lastUpdatedTime
    retv.dataVersion = this.dataVersion
    retv.latitude = this.latitude
    retv.longitude = this.longitude
    retv.layer = this.layer
    retv.guid = this.guid
    retv.name = this.name.convertToJ()
    return retv
}